package com.tmeone.erpone.controller;


import com.tmeone.erpone.entity.JsonResult;
import com.tmeone.erpone.entity.TShelves;
import com.tmeone.erpone.entity.TWare;
import com.tmeone.erpone.mapper.TShelvesMapper;
import com.tmeone.erpone.service.ITShelvesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;

/**
 * <p>
 *  货区控制器
 * </p>
 *
 * @author wzy
 * @since 2021-04-19
 */
@RestController
public class TShelvesController {
    @Autowired
    private ITShelvesService itShelvesService;

    @PutMapping("/updateWareCargo")
    public JsonResult updateWareCargo(@RequestBody TShelves shelvesNo){
        itShelvesService.updateShelves("1",shelvesNo.getShelvesNo());
        return new JsonResult(1,null);
    }

    @PutMapping("/updateShelvesById")
    public JsonResult updateShelvesById(@RequestBody TWare tWare){
        if(tWare.getTotalNum()!=null){
            int  totalNum = Integer.parseInt(tWare.getTotalNum());
            itShelvesService.updateShelvesById(tWare.getPName(),totalNum,tWare.getRemark(),tWare.getSId(),tWare.getCId());
        }
        return new JsonResult(1,null);
    }
    @PostMapping("/addShelvesAll")
    public JsonResult addShelvesAll(@RequestBody TShelves tShelves){
        itShelvesService.save(tShelves);
        return new JsonResult(1,null);
    }
}
